﻿@{
    ViewBag.Title = "类别查看";
    Layout = "~/Areas/SystemManage/Views/Shared/_Form.cshtml";
}
<script>

    var keyValue = $.request("keyValue");
    //if (keyValue.length > 0) {
    //    $("#ConfigCode").prop("disabled", "disabled");
    //}
    $(function () {
        if (!!keyValue) {
            $.ajax({
                url: "/SystemManage/ArticleCategory/GetFormJson",
                data: { keyValue: keyValue },
                dataType: "json",
                async: false,
                success: function (data) {
                    $("#form1").formSerialize(data);
                    initControl(data.ParentId);
                }
            });
        }
        
    });

    function initControl(currentId) {
        $("#ParentId").html("<option value=''>--请选择--</option>");
        var url = "/SysComponent/Controll/GetArticleCates";
        $("#ParentId").bindSelect({
            url: url,
            id: "Code",
            text: "Text",
            selected: currentId
        });
    }

    function submitForm() {
        if (!$('#form1').formValid()) {
            return false;
        }

        var Title = $("#Title").val();
        if (Title.length == 0) {
            $.modalMsg("分类名称不能为空");
            return false;
        }
        
        var data = $("#form1").formSerialize();
        if (data.ParentId !== undefined) { 
            data.ParentId = data.ParentId.replace("&nbsp;","");
        }
        $.submitForm({
            url: "/SystemManage/ArticleCategory/SubmitForm?keyValue=" + keyValue,
            param: data,
            success: function () {
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        });
    }
</script>

<form id="form1">
    <div style="padding-top: 20px; margin-right: 20px;">
        <table class="form">
            <tr>
                <th class="formTitle">分类名称</th>
                <td class="formValue">
                    <input id="Title" name="Title" type="text" class="form-control" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">分类简述</th>
                <td class="formValue">
                    <textarea id="ShortTitle" name="ShortTitle" type="text" class="form-control"></textarea>
                </td>
            </tr>
            <tr>
                <th class="formTitle">父级分类</th>
                <td class="formValue">
                    <select id="ParentId" name="ParentId" type="text" class="form-control">
                        <option value="">--请选择--</option>
                    </select>
                </td>
            </tr>
            <tr>
                <th class="formTitle" style="vertical-align:top">分类描述</th>
                <td class="formValue">
                    <textarea id="Description" name="Description" class="form-control"></textarea>
                </td>
            </tr>
            <tr>
                <th class="formTitle">排序</th>
                <td class="formValue">
                    <input id="SortCode" name="SortCode" type="text" class="form-control required" value="1" />
                </td>
            </tr>
            <tr>
                <th class="formTitle" style="height: 35px;">选项</th>
                <td class="formValue" style="padding-top: 1px;">
                    <div class="ckbox">
                        <input id="EnabledMark" name="EnabledMark" type="checkbox" checked="checked"><label for="EnabledMark">有效</label>
                    </div>
                </td>
            </tr>
            @*<tr>
            <th class="formTitle" valign="top" style="padding-top: 11px;">
                备注
            </th>
            <td class="formValue">
                <textarea id="Description" name="Description" class="form-control" style="height: 60px;"></textarea>
            </td>
        </tr>*@
        </table>
    </div>
</form>


@section Scripts{
    <!-- 配置文件 -->
    <script type="text/javascript">
      

        //var desc = $("#Description").html();
        //if (desc.length > 0) {
        //    console.log("Description初始化");
        //    ue.setContent(desc, false);
        //}
        initControl();
    </script>
}